//package com.example.hookdemo;
//
//import android.hardware.camera2.CameraDevice;
//import android.hardware.camera2.CameraManager;
//import android.os.Build;
//import android.os.Handler;
//
//import androidx.annotation.RequiresApi;
//
//import java.util.concurrent.Executor;
//
//import de.robv.android.xposed.IXposedHookLoadPackage;
//import de.robv.android.xposed.XC_MethodHook;
//import de.robv.android.xposed.XposedBridge;
//import de.robv.android.xposed.XposedHelpers;
//import de.robv.android.xposed.callbacks.XC_LoadPackage;
//
//public class HookToast implements IXposedHookLoadPackage {
//
//    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
//    @Override
//    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
//        XposedBridge.log("xposed package" + loadPackageParam.packageName);
////        if (loadPackageParam.packageName.equals("com.example.hookdemo")) {
////            XposedBridge.log(" has Hooked!");
////            Class clazz = loadPackageParam.classLoader.loadClass("com.example.hookdemo.MainActivity");
////            XposedHelpers.findAndHookMethod(clazz, "toastMessage", new XC_MethodHook() {
////                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
////                    super.beforeHookedMethod(param);
////                    XposedBridge.log("别看了，老子已经成功Hook");
////                }
////
////                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
////                    param.setResult("你已被劫持!!!");
////                }
////            });
////        }
//
//        //android.content.Intent
//
////        if (loadPackageParam.packageName.equals("android.content")) {
////            XposedBridge.log(" has Hooked!");
////            Class clazz = loadPackageParam.classLoader.loadClass("android.content.Intent");
////            XposedBridge.log(" has Hooked! clazz=" + clazz.getName());
////            XposedHelpers.findAndHookMethod(clazz, "setAction", new XC_MethodHook() {
////                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
////                    super.beforeHookedMethod(param);
////                    XposedBridge.log("成功Hook param=" + param.args[0]);
////                }
////
////                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
////                    param.setResult("你已被劫持!!! param=" + param.args[0]);
////                }
////            });
////        }
////        if (loadPackageParam.packageName.equals("com.example.hookdemo")) {
////            XposedHelpers.findAndHookMethod(Intent.class, "setAction", String.class,
////                    mRemoveSecureFlagHook);
////        }
//        XposedHelpers.findAndHookMethod(CameraManager.class, "openCamera", CameraDevice.StateCallback.class, Handler.class,
//                    mRemoveSecureFlagHook);
//        XposedHelpers.findAndHookMethod(CameraManager.class, "openCamera", Executor.class, CameraDevice.StateCallback.class,
//                mRemoveSecureFlagHook);
////        XposedHelpers.findAndHookMethod(Window.class, "setFlags", int.class, int.class,
////                mRemoveSecureFlagHook);
////        try {
////            XposedHelpers.findAndHookMethod(SurfaceView.class, "setSecure", boolean.class,
////                    mRemoveSetSecureHook);
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
//    }
//
//    private final XC_MethodHook mRemoveSecureFlagHook = new XC_MethodHook() {
//        @Override
//        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//            if ("android.media.action.IMAGE_CAPTURE".equals(param.args[0])) {
//                XposedBridge.log("成功Hook param=" + param.args[0]);
////                Method me = XposedHelpers.findMethodBestMatch(Intent.class, "setAction",
////                        "android.media.action.IMAGE_CAPTURE");
//                MainActivity activity = new MainActivity();
//                activity.openAlbum();
//            }else{
//                super.beforeHookedMethod(param);
//            }
//            // startActivityForResult(intent, CHOOSE_PHOTO);//打开相册
//        }
//
//        @Override
//        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//            MainActivity mainActivity = new MainActivity();
//            mainActivity.openAlbum();
//        }
//    };
//
//    private final XC_MethodHook mRemoveSetSecureHook = new XC_MethodHook() {
//        @Override
//        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//            param.args[0] = false;
//        }
//    };
//}
